;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Functions for retrieving and formatting keys
+(defsubst which-key--safe-lookup-key (keymap key)
+ "Version of `lookup-key' that allows KEYMAP to be nil. KEY is not checked."
+ (when (keymapp keymap) (lookup-key keymap key)))
+
(defun which-key--maybe-replace (string repl-alist &optional literal)
"Perform replacements on STRING.
REPL-ALIST is an alist where the car of each element is the text
(desc (cdr key-desc-cons))
(group (which-key--group-p desc))
(keys (concat (key-description which-key--current-prefix) " " key))
- (local (eq (lookup-key local-map (kbd keys)) (intern desc)))
+ (local (eq (which-key--safe-lookup-key local-map (kbd keys)) (intern desc)))
(key (which-key--maybe-replace
key which-key-key-replacement-alist))
(desc (which-key--maybe-replace
(or
(keymapp (key-binding prefix-keys))
;; Some keymaps are stored here like iso-transl-ctl-x-8-map
- (keymapp (lookup-key key-translation-map prefix-keys))
+ (keymapp (which-key--safe-lookup-key key-translation-map prefix-keys))
;; just in case someone uses one of these
- (keymapp (lookup-key function-key-map prefix-keys)))
+ (keymapp (which-key--safe-lookup-key function-key-map prefix-keys)))
(not which-key-inhibit))
(which-key--create-buffer-and-show prefix-keys))))